//
//  PS_WangDaiViewController.m
//  FinanceSupermarket
//
//  Created by 丹丹 on 2018/12/13.
//  Copyright © 2018年 xuezi. All rights reserved.
//

#import "PS_WangDaiViewController.h"
#import "PS_ShouTouViewController.h"
#import "PS_FuTouViewController.h"
#import "FSScrollContentView.h"
@interface PS_WangDaiViewController ()<FSSegmentTitleViewDelegate,FSPageContentViewDelegate>
{
    UIView * lineView;//滑动线
}
@property (nonatomic, strong) FSSegmentTitleView *titleView;
@property (nonatomic, strong) FSPageContentView *pageContentView;
@end

@implementation PS_WangDaiViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    self.nav_titleLabel.text = @"网贷返利";
    self.view.backgroundColor = RGBCOLOR(238, 238, 238);
    
    NSArray *titles  = @[@"首投返利",@"复投返利"];
    
    self.titleView = [[FSSegmentTitleView alloc]initWithFrame:CGRectMake(0, SafeAreaTopHeight, SCREEN_WIDTH, 45) titles:titles delegate:self indicatorType:FSIndicatorTypeNone];
    self.titleView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.titleView];
    
    NSMutableArray *childVCs = [[NSMutableArray alloc]init];
    PS_ShouTouViewController * sVC = [[PS_ShouTouViewController alloc]init];
    
    PS_FuTouViewController * fVC = [[PS_FuTouViewController alloc]init];
    
    [childVCs addObject:sVC];
    [childVCs addObject:fVC];

    
    self.pageContentView = [[FSPageContentView alloc]initWithFrame:CGRectMake(0,SafeAreaTopHeight+ 47, CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.view.bounds) - 60) childVCs:childVCs parentVC:self delegate:self];
    [self.view addSubview:self.pageContentView];
    
    float line_wight = SCREEN_WIDTH/2;
    lineView = [[UIView alloc]initWithFrame:CGRectMake(0, SafeAreaTopHeight+45, line_wight, 2)];
    lineView.backgroundColor = RGBCOLOR(238, 114, 111);
    [self.view addSubview:lineView];
    
    // Do any additional setup after loading the view.
}
#pragma mark --
- (void)FSSegmentTitleView:(FSSegmentTitleView *)titleView startIndex:(NSInteger)startIndex endIndex:(NSInteger)endIndex
{
    self.pageContentView.contentViewCurrentIndex = endIndex;
    lineView.frame = CGRectMake(SCREEN_WIDTH/2*endIndex, SafeAreaTopHeight+45,SCREEN_WIDTH/2, 2);
}

- (void)FSContenViewDidEndDecelerating:(FSPageContentView *)contentView startIndex:(NSInteger)startIndex endIndex:(NSInteger)endIndex
{
    self.titleView.selectIndex = endIndex;
    lineView.frame = CGRectMake(SCREEN_WIDTH/2*endIndex, SafeAreaTopHeight+45,SCREEN_WIDTH/2, 2);
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
